
const vm=new Vue({
    el:'.app',
    data:{
        // con:[]
        userName:'',
        content:'',
        time:Date.now(),
        allcon:[],
        items: Array.from({ length: 8 }),
        activeIndex:-1,
    },
    methods:{
        addcon() {
            if (this.userName.trim() === '' || this.content.trim() === '') {
                alert('用户名和留言内容不能为空！');
                return;
            }
            this.allcon.push({userName:this.userName,content:this.content,time:new Date(this.time).toLocaleString()});
            // console.log(new Date(this.time).toLocaleString())
            this.userName = '';
            this.content=''; 
        },
        deletecon(index) {
            this.allcon.splice(index, 1); 
        }
    }
})